package com.bigflexlib.x.mx.styles
{
	import mx.styles.CSSStyleDeclaration;
	import mx.styles.StyleManager;
	
	public class StyleUtil
	{

		
		
		/**
		 * 
		 * Set a style on the StyleManager using css path dot notation
		 * It only accepts two dots for now.
		 * 
		 * In the future this should support full path-like syntax with dots, array access, etc.
		 * 
		 * 
		 * 
		 * @param cssPath
		 * @param value
		 * 
		 */		
		public static function s( cssPath:String, value:* ):void
		{
			
			var parts:Array = cssPath.split( "." );
			
			if ( parts.length != 2 )
			{
				throw new Error( "Only simple path styles ( selector.styleProp ) are currently supported " );
			}
					
			var csd:CSSStyleDeclaration;
			
			csd = StyleManager.getStyleDeclaration( parts[ 0 ] );
			if ( ! csd )
				csd = new CSSStyleDeclaration( parts[ 0 ] );
			
			csd.setStyle( parts[1], value );
			
		}





		public static function g( cssPath:String ):*
		{
		

			var parts:Array = cssPath.split( "." );
			
			if ( parts.length != 2 )
			{
				throw new Error( "Only simple path styles ( selector.styleProp ) are currently supported " );
			}
					
			var csd:CSSStyleDeclaration;
			
			csd = StyleManager.getStyleDeclaration( parts[ 0 ] );
			
			if ( ! csd )
				return undefined;
			
			csd.getStyle( parts[1] );		
			
		
		
		}






	}
}